#ifndef _THREADPOLL_
#define _THREADPOLL_

#include <func.h>
#define BIG_FILE_SIZE 104857600
typedef struct task_s {
    int netfd;
    struct task_s * next;
} task_t;
typedef struct taskQueue_s {
    task_t * head;
    task_t * tail;
    int queueSize;
    pthread_mutex_t mutex;
    pthread_cond_t cond;
} taskQueue_t;
int initQueue(taskQueue_t *pqueue);
int enQueue(taskQueue_t *pqueue, int netfd);
int deQueue(taskQueue_t *pqueue);

typedef struct threadPool_s {
    pthread_t *tidArr;
    int workerNum;
    taskQueue_t taskQueue;
} threadPool_t;
typedef enum Commandname_s{
    CD,//0
    LS,//1
    PUTS,//2
    GETS,//3
    REMOVE,//4
    PWD,//5
    MKDIR,//6
    RMDIR,//7
    EXIT, //8
}CommandName;

typedef struct order_s{
    CommandName Name;   //命令名字
    char object[1024];  //命令操作对象，可以是目录或者文件路径
}order_t;
int initThreadPool(threadPool_t * pthreadPool, int workerNum);
int tcpInit(char *ip, char *port,int *psockfd);
void *threadFunc(void *arg);
int makeWorker(threadPool_t * pthreadPool);
int epollAdd(int epfd, int fd);
int epollDel(int epfd, int fd);
typedef struct train_s {
    int length;
    char data[1000];
} train_t;
int transfile(int netfd);
int passwdVerify(char *pName, char *pPasswd);
int get_salt(char *salt, char *passwd);
int cdCmd(char* path,char *orderobject);
int ls(int netfd,char* path);
int putFile(char* filename, int fd, char *path);
int getFile(char* filename, int fd, char *path);
int mmapSendFile(const char* filename, int netfd, off_t offset);
int Remove(int netfd, char* path,char* filename);
int pwd(int netfd,char* path,int idx);
int Mkdir(int netfd,char* path,char* name);
int Rmdir(int netfd,char* path,char* name);
#endif
